import request from '@/config/axios'

// 服务开通城市 VO
export interface OpenCityVO {
  id: number // 城市id
  type: number // 类型，省市县乡
  name: string // 城市名称
  parentId: number // 城市的上一级
}

// 服务开通城市 API
export const OpenCityApi = {
  // 查询服务开通城市分页
  getOpenCityPage: async (params: any) => {
    return await request.get({ url: `/peizhen/open-city/page`, params })
  },

  // 查询服务开通城市详情
  getOpenCity: async (id: number) => {
    return await request.get({ url: `/peizhen/open-city/get?id=` + id })
  },

  // 新增服务开通城市
  createOpenCity: async (data: OpenCityVO) => {
    return await request.post({ url: `/peizhen/open-city/create`, data })
  },

  // 修改服务开通城市
  updateOpenCity: async (data: OpenCityVO) => {
    return await request.put({ url: `/peizhen/open-city/update`, data })
  },

  // 删除服务开通城市
  deleteOpenCity: async (id: number) => {
    return await request.delete({ url: `/peizhen/open-city/delete?id=` + id })
  },

  // 导出服务开通城市 Excel
  exportOpenCity: async (params) => {
    return await request.download({ url: `/peizhen/open-city/export-excel`, params })
  },

  // 获取所有城市信息
  getAllCity: async () => {
    return await request.get({ url: `/peizhen/open-city/getAllCity` })
  },

  // ==================== 子表（具体服务） ====================

  // 获得具体服务分页
  getProgramPage: async (params) => {
    return await request.get({ url: `/peizhen/open-city/program/page`, params })
  },
  // 新增具体服务
  createProgram: async (data) => {
    return await request.post({ url: `/peizhen/open-city/program/create`, data })
  },

  // 修改具体服务
  updateProgram: async (data) => {
    return await request.put({ url: `/peizhen/open-city/program/update`, data })
  },

  // 删除具体服务
  deleteProgram: async (id: number) => {
    return await request.delete({ url: `/peizhen/open-city/program/delete?id=` + id })
  },

  // 获得具体服务
  getProgram: async (id: number) => {
    return await request.get({ url: `/peizhen/open-city/program/get?id=` + id })
  },
}
